package com.lulalei.dbviewer.strategy;

import com.lulalei.dbviewer.commons.exception.CustomizeException;
import com.lulalei.dbviewer.db.DBService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class DBStrategyManager {

    private final List<DBService> dbServices;

    public DBService getDBService(String type) throws CustomizeException {
        for (DBService dbService : dbServices) {
            if (dbService.isOwn(type)){
                return dbService;
            }
        }
        throw new CustomizeException("暂未适配的数据类型");
    }

}
